package com.wzy.authority.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @program: authorityManagement
 * @description: Swagger2整合springBoot
 * @author: 1
 * @create: 2020-03-25 17:11
 **/
@Configuration      // 这是控制开关
@EnableSwagger2     // 这是用了 swagger2
@ComponentScan(basePackages = {"com.wzy.authority.controller"})     //这里可以不用
public class SwaggerConfig extends WebMvcConfigurerAdapter {

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }


    private ApiInfo apiInfo() {
        //title  后期显示为你的主标题
        //description 说明
        //version    版本
        return new ApiInfoBuilder()
                .title("用户管理后台 API 文档")
                .description("HTTP对外开放接口")
                .version("C03")
                .build();
    }

}